/**
 * ERPs
 * Cuatrovientos
 */
package info.pello.greet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Greet
 *  @author Carlos Rota
 */
@WebServlet(description = "Servlet that greets", urlPatterns = { "/Greet" })
public class Greet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Greet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter output = response.getWriter();
		String name=  request.getParameter("name");
		for (int i=0;i<Integer.parseInt(request.getParameter("veces"));i++){
		output.print("Good <b>morning</b> "+ name +"</br>");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter output = response.getWriter();
		String Login = request.getParameter("Login");
		String Password = request.getParameter("Password");
		
		
		System.out.println("doPost methos was invoked");
		output.write("This page was a scam, now we have your user and password!!</br>");
		output.write("Your user is: "+ Login);
		output.write("</br>And your oh so secret password is: "+Password);
		}

}
